#!/bin/bash

if [ `whoami` != "root" ]; then
    echo "需要以root用户执行"
    exit -1;
fi

echo 开始替换设备树-----------------------------------
if [ ! -f dt.img ]; then
    echo dt.img 文件不存在
    exit -1;
fi

correct_md5=f8d221f25b3c12cfb84e01f89f9f5d63


md=$(md5sum dt.img | awk '{print $1}')
if [ "$md" = "$correct_md5" ]; then
    echo "MD5验证通过: $md"
    dd if=dt.img of=/dev/mmcblk0 count=2048 seek=88076 bs=512
    # dd if=dt.img of=/dev/mmcblk0 count=2048 seek=208908 bs=512
    echo 替换设备树完成-----------------
fi
